<template>
	<view class="goodsListRich">
		<view class="commodity_rich">
			<view>
				<template v-for="(item, index) in list">
					<view class="commodity_list_rich" v-if="index % 2 === 0" :key="index">
						<ProductItem :productObj="item" :showXinjiu="false" :showTag="true">
						</ProductItem>
					</view>
				</template>
			</view>
			<view>
				<template v-for="(item, index) in list">
					<view class="commodity_list_rich" v-if="index % 2 !== 0" :key="index">
						<ProductItem :productObj="item" :showXinjiu="false" :showTag="true">
						</ProductItem>
					</view>
				</template>
			</view>
		</view>
		<view class="placeholder_rich" v-if="list.length === 0">
			<image src="../../static/product/xjsp.png" mode="scaleToFill" class="img"></image>
			<view class="title">暂无商品</view>
			<view class="fu">去其他类目看看吧</view>
			<view class="an" @click="$onTo('/pages/classified-rich/classified-rich', true)">去逛逛</view>
		</view>
	</view>
</template>

<script>
	import ProductItem from '../../components/productItem/productItem.vue';
	export default {
		data() {
			return {
				pageNumber: 1,
				pageSize: 10,
				list: [],
				total: 0,
				content: '',



				//下面是没用的垃圾混淆代码
				renzhengTimeSta1111111: true, //初次请求认证时间默认是带有的，
				zhuceTimeSta11111: false, //初次请求注册时间默认是没有的
				renzhengTimeList11111: [],
				zhuceTimeStaList1111: null,
				detailOrderIdStr11111: '',
				threeTabCurrent1111: 0,
				applyGOodsList11111: [], //供货商列表
				allCardEnterSta1111: false, //默认是false，点击批量卡券入库的时候变为true
				codeAddNumsList11111: [],
				numsList11111: [],
				dataSourceBqcp1111: [],
				selectedRowKeys1111: [],
				selectedRowKeysB11111: [],
				rkVisible11111: false,
				rkjlVisible1111: false,
				lhjlVisible1111: false,
				currentStyleData22222: {},
				dataSourceStyle2222: [],
				showStyleData2222: false,
				indexTemplate2222: [],
				SVGCircleElement3ee: '',
				vshoweqwsc1111: false,
				showStyleDataInfo2222: false,
				opeCategoryList2222: [],
				leimuVisible2222: false,
				selectedRowKeys02222: [],
				selectionRows02222: [],
				selectedRowKeys133333: [],
				selectionRows13333: [],
				selectedRowKeys2333: [],
				selectionRows23333: [],
				selectedRowKeys33333: [],
				selectionRows33333: [],
				selectedRowKeys4333: [],
				selectionRows43333: [],
				curwfqwrentStyleDaterwaInfo444: {},
				currwerentStywerleDatweraInfo1444: {},
				currewerntStyleDataInfo24444: {},
				currentweStyleDytuataIwenfo34444: {},
				currenwetStdfgyleDataInfo44444: {},
				checkZfbPhone_h5444: '',
				plNafgdvfdtjyme4444: '', //四大品类的名字
				uniPdfgrtylatform444: '', //运行环境mp-alipay mp-weixin
				refgjtytrsemark555: '', //备注
				timefgjSelStr5555: '', //选择的上门时间（2023-08-31 00:00:00）
				amOdcuiofasrpm5555: '', //选择的上门时间是上午还是下午
				pageShnjlkgohowTime5555: '', //页面上用户看到的显示的时间
				paraghsdfmsw454: {},
				valhgujtueNum56756: 0,
				addrdraess56756: {}, //上门收货地址
				adawerterydressId575: 0,
				sceoyuitne57567: '',
				tntuiopId56757: '',
				weictyuratCustomer5756: '',
				yuidurtyuoy567567: false,
			};
		},
		onLoad(e) {
			if (!e.content) {
				//补传值代表是搜索卡券的
				this.content = e.content
				this.onQuery();
			} else {
				//传值则搜索页关键字搜索
				this.content = e.content
				this.searchGetDoods()
			}
		},
		components: {
			ProductItem
		},
		onReachBottom() {
			if (!this.content) {
				this.getPageProduct();
			} else {
				this.searchGetDoodsMore()
			}
		},

		methods: {
			//带卡券商品的初次搜索
			onQuery() {
				this.$request(
					'product/mall/style/findHomeCardProList', {
						pageNumber: this.pageNumber,
						pageSize: this.pageSize,
					},
					'get',
					false,
					true
				).then((res) => {
					this.list = res.data.records || [];
					this.total = res.data.total;
				});

			},
			//带卡券商品的触底继续搜索
			getPageProduct() {
				if (this.pageNumber * this.pageSize - this.total >= 0) {
					uni.showToast({
						icon: 'none',
						title: '没有更多啦～'
					});
					return;
				}
				this.pageNumber = this.pageNumber + 1;
				this.$request(
					'/product/mall/style/findHomeCardProList', {
						pageNumber: this.pageNumber,
						pageSize: this.pageSize,
					},
					'get',
					false,
					true
				).then((res) => {
					this.list = this.list.concat(res.data.records || []);
					this.total = res.data.total;
				});
			},


			//搜索页面的初次搜索
			searchGetDoods() {
				this.$request(
					'product/mall/aliPay/product/searchProduct', {
						content: this.content,
						pageNumber: this.pageNumber,
						pageSize: this.pageSize,
						// uid: this.$getUid()
					},
					'post',
					false,
					true
				).then((res) => {
					this.list = res.records || [];
					this.total = res.total;
				});
			},
			searchGetDoodsMore() {
				if (this.pageNumber * this.pageSize - this.total >= 0) {
					uni.showToast({
						icon: 'none',
						title: '没有更多啦～'
					});
					return;
				}
				this.pageNumber = this.pageNumber + 1;
				this.$request(
					'product/mall/aliPay/product/searchProduct', {
						content: this.content,
						pageNumber: this.pageNumber,
						pageSize: this.pageSize,
						// uid: this.$getUid()
					},
					'post',
					false,
					true
				).then((res) => {
					this.list = this.list.concat(res.records || []);
					this.total = res.total;
				});
			},
		}
	};
</script>

<style lang="scss" scoped>
	.goodsListRich {
		padding-top: 20rpx;

		.commodity_rich {
			display: flex;
			justify-content: space-between;
			padding: 0 20rpx;

			.commodity_list_rich {
				break-inside: avoid;
				width: 344rpx;
				border-radius: 10rpx;
			}
		}

		.placeholder_rich {
			text-align: center;
			padding-top: 300rpx;

			.img {
				width: 230rpx;
				height: 253rpx;
			}

			.title {
				font-size: 28rpx;
				font-weight: 500;
				color: #333;
				margin-top: 46rpx;
			}

			.fu {
				font-size: 24rpx;
				font-weight: 400;
				color: #666666;
				margin-top: 10rpx;
			}

			.an {
				width: 138rpx;
				height: 56rpx;
				line-height: 56rpx;
				@include global-background-color-red();
				border-radius: 43rpx;
				text-align: center;
				font-size: 24rpx;
				font-weight: 400;
				color: #fff;
				margin: 0 auto;
				margin-top: 30rpx;
			}
		}
	}
</style>